<template>
	<view style="padding-bottom: 150rpx;">
		<goods-order-address :address="address"></goods-order-address>

		<!-- 商品详情 -->
		<view class="u-m-t-20">
			<view class="u-p-30 bg-white">
				<block v-for="(v,indey) in shopList" :key='indey'>
					<goods-order-goods-item :item="v"></goods-order-goods-item>
				</block>
				<view class="">
					<u-cell-item title="购买数量" :arrow="false" value="1"></u-cell-item>
					<u-cell-item title="商品金额" :value="'¥' + details.order_total_price" :arrow="false"></u-cell-item>
					<u-cell-item title="运费" :value="'¥'+ details.express_price" :arrow="false"></u-cell-item>
					<u-cell-item title="实付金额" :value="'¥'+ details.order_pay_price" :arrow="false"></u-cell-item>
				</view>
			</view>
		</view>
		
		<view class="position-fixed left-0 right-0 bottom-0 " style="z-index: 2;">
      <view class="safe-bottom bg-white">
        <view class="flex align-center justify-between u-p-x-30 bg-white border-top" style="height: 100rpx;">
        	<view class="">
        		<text class="u-font-28 u-m-r-20">实付金额</text> 
        		<text class="u-font-28 text-danger font-weight-bold">¥{{details.order_pay_price}}</text> 
        	</view>
        	<view class="">
        		<dy-button width="200rpx" size="default" @click="sureOrder">立即支付</dy-button>
        	</view>
        </view>
      </view>
			
		</view>
	</view>
</template>

<script>
	import { SeckillCenterApi } from '@/api/serves.js'
	export default {
		data() {
			return {
				seckill_log_id: '',               // 拼团还是参团
				details: {},
				address: { Area: null},  // 收货地址
				shopList: [],            // 店铺商品list
			};
		},
		onLoad(options) {
      uni.$on('addressClick',()=> {
        this._orderBuyNow()
      })
			console.log('options', options);
			this.seckill_log_id = options.id
			this._orderBuyNow()
		},
		methods:{
			_orderBuyNow() {
				SeckillCenterApi.seckillBuyNow({ seckill_log_id: this.seckill_log_id }).then(res => {
					console.log('订单详情', res)
					if (res.code == 1) {
						this.details = res.data
						this.address = res.data.address
						if (this.address) {
							this.address.Area = Object.values(this.address.Area);
						}
						this.shopList = res.data.goods_list
					}
				})
			},
			sureOrder() {
				uni.showLoading()
				SeckillCenterApi.orderbuyNow_pay3({ seckill_log_id: this.seckill_log_id }).then((res)=> {
					console.log('商品下单成功，待支付', res);
					uni.hideLoading()
					if(res.code == 1) {
						let params = {
						  order_no: res.data.order_no,
						  from: 'seckill',
						}
						uni.redirectTo({
							url: '/pages/goodsDetail/goodsOrderPay/goodsOrderPay?orderInfo=' + JSON.stringify(params)
						})
					}else {
						this.$Toast(res.msg)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
.u-cell[data-v-65423b64] {
	padding: 15rpx 0;
}
::v-deep .u-cell_title[data-v-65423b64] {
	font-weight: bold;
}
.u-field[data-v-1c764f86] {
	padding-left: 0;
	padding-right: 0;
}
</style>
